package com.chuanjiabao.wisdom.ui.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 处理图片放大缩小时的异常处理
 */
public class ImageOriginPager extends ViewPager {

    public ImageOriginPager(@NonNull Context context) {
        super(context);
    }

    public ImageOriginPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    /**
     * 重写onInterceptTouchEvent()方法来解决图片点击缩小时候的Crash问题
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        try {
            return super.onInterceptTouchEvent(event);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
        return false;
    }

}
